<template>
    <div class="tourist-list">
        <div class="search-box">
            <div class="items">
                <span class="item-title">类型：</span>
                <span class="item-list">
                    <a  href="javascript:void(0)" @click="handleSearchClickType('all')" :class="searchData.type_sub_id === 'all' ? 'selected-item' : ''">全部</a>
                    <a href="javascript:void(0)" @click="handleSearchClickType(id)" v-for="(item, id) in typeOption" :key="id" :class="searchData.type_sub_id === '' + id ? 'selected-item' : ''">{{item.cn_name|fieldDecrypt}}</a>
                </span>
            </div>
            <div class="items">
                <span class="item-title">区域：</span>
                <span class="item-list">
                    <a  href="javascript:void(0)" @click="handleSearchClickProvince('all')" :class="searchData.province_id === 'all' ? 'selected-item' : ''">全部</a>
                    <a href="javascript:void(0)" @click="handleSearchClickProvince(id)" v-for="(item, id) in cityOption" :key="id" :class="searchData.province_id === '' + id ? 'selected-item' : ''">{{item.label|fieldDecrypt}}</a>
                </span>
            </div>
        </div>
        <br/>
        <div class="item-content">
            <ul class="item-content-list">
                <li  v-for="(_item, _index) in touristData" :key="_index">
                    <router-link :to="'tourist/detail/' + _item.hstr">
                        <div class="pic_add"><img alt="景点" :src="_item.image_url|fieldDecrypt" data-original-background="none" style="background: none;width: 100%;"></div>
                        <div class="city_name"></div>
                    </router-link>
                    <div class="item-name">
                        <p>{{_item.en_name|fieldDecrypt}}<span class="right type-name">{{_item.city_name|fieldDecrypt}}</span></p>
                    </div>
                </li>
            </ul>
        </div>
        <el-pagination
                background
                layout="prev, pager, next"
                @current-change="handleCurrentChange"
                :hide-on-single-page="false"
                :page-size="searchData.page_size"
                :total="total">
        </el-pagination>
    </div>
</template>

<script>
    import 'swiper/css/swiper.css'

    import http from "../util/http";

    export default {
        name: "touristList",
        components: {
        },
        data() {
            return {
                total:0,
                searchData: {
                    'page_size': 20,
                    'page_index': 1,
                    'type_sub_id' : 'all',
                    'province_id':'all',
                    'city_id':'all',

                },
                touristData : [],
                cityOption : [],
                typeOption : []
            }
        },
        mounted() {
            this.getDataList();
        },
        methods:{
            getDataList: function () {
                http.post("tourist/list", this.searchData).then(res => {
                    if (res.success === true) {
                        this.touristData    = res.data.data;
                        this.total          = res.data.total;
                        this.cityOption     = res.data.city_option;
                        this.typeOption     = res.data.type_option;
                        console.log(this.touristData);
                    }
                });
            },
            handleSearchClickType: function(typeId) {
                this.searchData.type_sub_id = typeId;
                this.searchData.page_index = 1;
                this.getDataList();
            },
            handleSearchClickProvince: function (provinceId) {
                this.searchData.province_id = provinceId;
                this.searchData.page_index = 1;
                this.getDataList();
            },
            handleSearchClickCity: function (cityId) {
                this.searchData.city_id = cityId;
                this.searchData.page_index = 1;
                this.getDataList();
            },
            handleCurrentChange: function (pageIndex) {
                this.searchData.page_index = pageIndex;
                this.getDataList();
            }
        }

    }
</script>

<style lang="scss">
    @import './../assets/scss/config.scss';
    @import './../assets/scss/reset.scss';
    @import './../assets/scss/mixin.scss';
    .tourist-list {
        min-width: 1200px;
        width: 1200px;
        margin: 0 auto;
        position: relative;
        .search-box {
            padding: 5px 10px;
            border-radius: 0;
            position: relative;
            z-index: 1;
            .items {
                line-height: 30px;
                padding: 8px 10px;
                border-bottom: 1px dashed #D8D8D8;
                .item-title {
                    display: inline-block;
                    *display: inline;
                    *zoom: 1;
                    color: #999;
                    margin-right: 15px;
                    vertical-align: top;
                    font-size: 14px;
                    font-weight: bold;
                }
                .item-list {
                    width: 1082px;
                    _width: 1078px;
                    display: inline-block;
                    *display: inline;
                    *zoom: 1;
                    font-size: 14px;
                    a.selected-item {
                        color: #ff6600;
                        font-weight: bold;
                        margin-right: 20px;
                    }

                    a {
                        margin-right: 20px;
                        display: inline-block;
                        *display: inline;
                        *zoom: 1;
                        cursor: pointer;
                        &:visited {
                            color: #333333;
                            text-decoration: none;
                            outline: none;
                        }

                    }
                }
            }
        }
        .item-content {
            .item-content-list {
                overflow: hidden;
                width: 1220px;
                li {
                    float: left;
                    width: 293px;
                    margin: 0 10px 10px 0;
                    overflow: hidden;
                    position: relative;
                    &:hover {
                        .item-name {
                            border-bottom: 2px solid #2064c8;
                            margin-bottom: 0
                        }
                        a .pic_add img {
                            bottom: 8px;
                            transition: bottom .3s
                        }
                    }
                    a {
                        display: block;
                        width: 100%;
                    }
                    img {
                        display: block;
                        width: 100%;
                        margin-top: -20px;
                        position: relative;
                        bottom: 0;
                        transition: bottom .3s;
                    }
                    .pic_add {
                        height: 160px;
                        width: 100%;
                        overflow: hidden;
                    }
                    .city_name {
                        position: absolute;
                        font: 12px/14px Microsoft yahei;
                        color: #fff;
                        background: #003679;
                        top: 135px;
                        left:10px;
                        padding: 3px;
                        border-radius: 3px;
                    }
                    .mask_num {
                        background: rgba(0,0,0,.5) !important;
                        background: #000;
                        filter: alpha(opacity=50);
                        width: 100px;
                        height: 100px;
                        position: absolute;
                        left: 50%;
                        top: 40px;
                        margin: 0 0 0 -40px;
                        border-radius: 50px;
                        text-align: center;
                        font: 18px/24px Microsoft yahei;
                        color: #fce639;
                        display: none;
                        cursor: pointer;
                    }
                    .item-name {
                        padding: 5px;
                        background: #f7f7f7;
                        border-bottom: 1px solid #ccc;
                        margin-bottom: 1px;
                        p {
                            color: #333333;
                            font: 14px/30px Microsoft yahei;
                            .type-name {
                                font-size: 10px;
                                color: #f55;
                            }
                        }
                    }
                }
            }
        }
    }

</style>
